﻿using System;

namespace Practice
{
    public delegate void Job(); // 任务列表委托

    class She
    {
        private event Job BoyFriendJobs = null; // 男朋友任务列表

        public void Command()
        {
            if (BoyFriendJobs != null) // 有男朋友的时候，发号施令
            {
                BoyFriendJobs();
            }
            else
            {
                Console.WriteLine("原来我还没有男朋友啊...");
            }
        }

        public void AddJob(Job job) // 动态添加男朋友的任务，注意传入一个Job类型的方法
        {
            BoyFriendJobs += job;
        }
    }

    class He
    {
        public void BuyTrainTicket() // 男朋友的任务
        {
            Console.WriteLine("买车票");
        }

        public void BuyCinemaTicket()
        {
            Console.WriteLine("买电影票");
        }

        public void BuyFood()
        {
            Console.WriteLine("买吃的");
        }
    }

    class Program
    {
        public static void Main(string[] args)
        {
            She she = new She();
            He he = new He();
            she.AddJob(he.BuyTrainTicket); // 添加男朋友任务
            she.AddJob(he.BuyFood);
            she.AddJob(he.BuyCinemaTicket);
            she.Command();

            Console.ReadKey();
        }
    }
}